package com.base.action;

import java.util.List;

import com.common.bean.Datadict;
import com.common.bean.Dict;
import com.common.util.PagerModel;

public class DictManagerAction extends DictAbstractAction {

	private static final long serialVersionUID = 5457444966712888080L;
	
	private Dict dict;
	
	private Datadict datadict;
	
	private List dictlist;
	
	private List datadictlist;
	
	private PagerModel pm;
	
	private String typecode;
	
	private Long typeid;
	
	@Override
	public String execute() throws Exception {
		int offset = 0;
		int pagesize = 10;

		try{
			offset = Integer.parseInt(getRequest().getParameter("pager.offset"));
		}catch(Exception e){
		}
		
//		dictlist = dictService.findAllDict();
		pm = dictService.findAllDict(offset, pagesize);
		return SUCCESS;
	}
	
	public String findAllDetail() {
		int offset = 0;
		int pagesize = 5;

		try{
			offset = Integer.parseInt(getRequest().getParameter("pager.offset"));
		}catch(Exception e){
		}
		
//		datadictlist = dictService.findDictDetail(typecode);
		pm = dictService.findDictDetail(typecode, offset, pagesize);
		return SUCCESS;
	}
	
	public String addDict() {
		dict = new Dict();
		return SUCCESS;
	}
	
	public String addDictdetails() {
		datadict = new Datadict();
		return SUCCESS;
	}
	
	public String doCreateDict() {
		dictService.addDict(dict);
		return SUCCESS;
	}
	
	public String doCreateDataDict() {
		dictService.addDictDetail(datadict,typecode);
		return SUCCESS;
	}
	
	public String removeDict() {
		dictService.removeDict(typecode);
		return SUCCESS;
	}
	
	public String removeDatatict() {
		dictService.removeDictDetail(typeid);
		return SUCCESS;
	}

	public Datadict getDatadict() {
		return datadict;
	}

	public void setDatadict(Datadict datadict) {
		this.datadict = datadict;
	}

	public List getDatadictlist() {
		return datadictlist;
	}

	public void setDatadictlist(List datadictlist) {
		this.datadictlist = datadictlist;
	}

	public Dict getDict() {
		return dict;
	}

	public void setDict(Dict dict) {
		this.dict = dict;
	}

	public List getDictlist() {
		return dictlist;
	}

	public void setDictlist(List dictlist) {
		this.dictlist = dictlist;
	}

	public String getTypecode() {
		return typecode;
	}

	public void setTypecode(String typecode) {
		this.typecode = typecode;
	}

	public PagerModel getPm() {
		return pm;
	}

	public void setPm(PagerModel pm) {
		this.pm = pm;
	}

	public Long getTypeid() {
		return typeid;
	}

	public void setTypeid(Long typeid) {
		this.typeid = typeid;
	}
	
	
}
